#define _CRTDBG_MAP_ALLOC
#include "vm.h"
#ifdef _MSC_VER
#include <crtdbg.h>
#pragma comment(lib,"libzb.lib")
#else
#include <unistd.h>
#endif
using namespace logo;

int main(int argc, char* argv[])
{
	int opt = 0;
	std::wstring filename = L"";
#ifdef _MSC_VER
	for (int i = 0; i<argc; i++)
	{
		if (argv[i] != "")
		{
			filename = atow(argv[i]);
		}
	}
#else
	while ((opt = getopt(argc, argv, "f:")) != -1)
	{
		switch (opt)
		{
		case 'f':
			filename = atow(optarg);
			break;
		}
	}
#endif
	lvm vm;
	if (vm.Init(filename))
	{
		vm.Run();
	}
#ifdef _MSC_VER
	_CrtDumpMemoryLeaks();
#endif
	return 0;
}